/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */

/**
 * @version runner.h 0.0.1
 * @package Comoro
 * @author Dr.NP <np@bsgroup.org>
 * 
 * Center server runner header
 */

#include <lua.h>

// Constants
#define MAX_RUNNER						64

#define FUN_INIT							"proc_init"
#define FUN_LOAD							"proc_load"
#define FUN_GO							"proc_cmd"
#define FUN_OFFLINE						"proc_offline"

//#define TBL_RUNNER_LIST					"runner_list"

// Runner struct
struct runner
{
	int runner_id;
	int mysql_env_id;
	char *runner_name;
	char *script_filename;
	lua_State *state;
	char is_loaded;
	char need_login;
	int load_time;
};

/* BEGIN OF FUNCTION DEFINE */
int runner_init						();
int runner_new						(int);
int runner_add						(struct runner *, int);
int runner_del						(struct runner *);
struct runner * runner_get			(int);
int runner_get_mysql_env				(lua_State *);
int runner_reload						(int);
int runner_load_script				(struct runner *, char *, char *);
int runner_unload_script				(struct runner *);
void runner_go						(int, int, unsigned int, char **, unsigned int);
void runner_offline					(int, int);
void runner_call						(lua_State *, char *, int, char **, unsigned int);

void runner_clear_stack				(lua_State *);
void runner_dump_stack				(lua_State *);
/* END OF FUNCTION DEFINE */
